﻿
#ifndef __DEBUGUTILITIES_H__
#define __DEBUGUTILITIES_H__
#include <string>
#include <sstream>
#include <iostream>
#include <cstdlib>
#include "Object.h"
#include <typeinfo>
#define typeName(var) typeid(var).name()
#define DEBUG_OS

using namespace std;

class DebugUtilities : public Object
{
	public:
		inline virtual void informError(const char* str, bool exit_ = true)const
		{
			cout << "************error***************";
			cout << (str ? str : "");
			cout << *this;
		}

		static inline void staticInformError(const char* str, bool exit_ = true)
		{
			cout << "************error***************";
			cout << (str ? str : "");
		}

		inline virtual int inform(const char* str, int i=0)const
		{
#ifdef DEBUG_OS
			cout << str << endl;
#endif
            return i;
		}
		inline friend ostream& operator << (ostream& os, const DebugUtilities& o)
		{
			ostringstream oss;
			oss << o;
			os << oss.str();
			return os;
		}

		inline friend ostringstream& operator<<(ostringstream& oss, const DebugUtilities& o)
		{
			oss << "DebugUtilities::\n*******************************************************************************\n";				// TO-DO ����ַ�
			return oss;
		}
		virtual ~DebugUtilities() {}

#ifdef DEBUG_OS
		void assert(bool t, char* const msg = "\0", char* const errorMsg = "\0")const;
		void static staticAssert(bool t, char* const msg = "\0", char* const errorMsg = "\0");
#else
		void inline assert(bool t, char* msg = NULL)const {};
		void static inline staticAssert(bool t, char* const msg = "\0", char* const errorMsg = "\0") {}
#endif
		void must(bool t, char* const msg = "", char* const errorMsg = "")const;
};

#endif /*__DEBUGUTILITIES_H_*/

